package com.ygp.threadlocal;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.Map;
import java.util.zip.ZipInputStream;

/**
 * <Description> <br>
 *
 * @author linmiaolai@sanyygp.com<br>
 * @version 1.0<br>
 * @date 2021/08/27 <br>
 */
public class ThreadLocalTest {

    /*private static ThreadLocal<Map<String, Object>> threadLocalForInfo
            = ThreadLocal.withInitial(HashMap::new);*/

    private static ThreadLocal<Integer> count = new ThreadLocal<>();

    public static void main(String[] args) {
        UserInfoStore userInfoStore = new UserInfoStore();
        Thread thread1 = new Thread(userInfoStore, "thread-1");
        thread1.start();

    }


    private static class UserInfoStore implements Runnable {
        @Override
        public void run() {
//            String name = Thread.currentThread().getName();
//            String token = name + "::token";
//            String userInfo = name + "::userInfo";
//            Map<String, Object> info = new HashMap<>();
//            info.put("token", token);
//            info.put("userInfo", userInfo);
//            threadLocalForInfo.set(info);
//            for (Map.Entry<String, Object> each : threadLocalForInfo.get().entrySet()) {
//                System.out.println(each.getKey() + ":" + each.getValue());
//            }
            for (int i = 0; i < 16; i++) {
                count.set(1);
            }

        }
    }
}
